package com.jyu.apts.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.jyu.apts.entityEnum.QRCodeStatusEnum;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="qrCode")
public class QRCode {
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	long id;
	@Column(unique=true)
	String code;
	@Column
	Integer type;
	@Column
	Integer status = QRCodeStatusEnum.UNUSED.getType();
	@ManyToOne
	User author;
	@Lob//不使用默认类型longtext
    @Column(columnDefinition="text")
	String dataValues;
	@OneToMany(mappedBy="normalQRCode",cascade={CascadeType.REMOVE})
	List<ItemProcessRecord> itemProcessRecords;
	@ManyToOne
	ItemProcessRecord itemProcessRecord;
	@ManyToOne
	ItemBatchRecord itemBatchRecord;
	@ManyToOne
	QRCodeTemplate qrCodeTemplate;
	
}
